package com.mingtu.jgspatrol.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.jgspatrol.R;
import com.mingtu.jgspatrol.bean.MyReportRecordBean;

public class MyRecordReportAdapter extends BaseQuickAdapter<MyReportRecordBean.PageBean.ListBean, BaseViewHolder> {
    private Context context;

    public MyRecordReportAdapter(Context context) {
        super(R.layout.item_my_record_report);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MyReportRecordBean.PageBean.ListBean listBean) {
        String eventCode = listBean.getEventCode();
        String id = listBean.getId();
        String createTime = listBean.getCreateTime();
        String address = listBean.getAddress();
        String tag = listBean.getTag();
        String type = listBean.getType();
        boolean isUpload = listBean.isUpload();

        TextView tvStatus = helper.getView(R.id.tv_status);
        TextView tvType = helper.getView(R.id.tv_type);

        if (!StringUtils.isEmpty(eventCode)) {
            helper.setText(R.id.tv_event_code, "编号：" + eventCode);
        }
        if (!StringUtils.isEmpty(createTime)) {
            helper.setText(R.id.tv_create_time, createTime);
        }
        if (!StringUtils.isEmpty(address)) {
            helper.setText(R.id.tv_address, address);
        }
        if (isUpload) {
            tvStatus.setText("已上传");
            tvStatus.setSelected(true);
            tvStatus.setVisibility(View.GONE);
        } else {
            tvStatus.setText("待上传");
            tvStatus.setSelected(false);
            tvStatus.setVisibility(View.VISIBLE);
        }

        if (!StringUtils.isEmpty(tag)) {
            tvType.setText(tag);
        }
    }


}
